//
//  health
//
//  Created by apple on 2021/10/26.
//  Copyright © 2021 zglee. All rights reserved.
//mj我的（知痛风）

#import "MineController.h"
#import "SettingController.h"
#import "MyProfileController.h"
#import "NotesGuideVC.h"
#import "AboutController.h"

@interface MineController ()

@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *groupNameLabel;
@end

@implementation MineController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.scrollView.alwaysBounceVertical = YES;
    [self setContentInsetNever:self.scrollView];
    [self.navigationController setNavigationBarHidden:true animated:NO];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [self updateUI];
}

- (void)updateUI {
    NSString *name = UserManager.shared.userModel.userName ?: UserManager.shared.userModel.email;
    self.nameLabel.text = name ?: UserManager.shared.userModel.phoneNumber.mj_securePhoneNumber;
    self.groupNameLabel.text = UserManager.shared.userModel.groupName.length ? UserManager.shared.userModel.groupName : MJUILocalizedString(@"Group name has not been set yet");
    [self.iconImageView mj_setHeadImageWithURLString:UserManager.shared.userModel.headPic gender:UserManager.shared.userModel.gender];
}

- (IBAction)handleInfoButtonEvent:(UIButton *)sender {
    MyProfileController *vc = [[MyProfileController alloc]init];
    [self.navigationController pushViewController:vc animated:true];
}

- (IBAction)handleItemButtonEvent:(UIButton *)sender {
    if (sender.tag == 0) {
        NotesGuideVC *vc = [[NotesGuideVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    if (sender.tag == 1) {
        SettingController *vc = [[SettingController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    if (sender.tag == 2) {
        AboutController *vc = [[AboutController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

@end
